Skip to content

Patch implementation of Const.unapply #10583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2020

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Dec 1, 2020

  • Make sure the extrators does not match classes. This should be done using reflection.
  • Do not match '{null} to avoid accidental NPEs.
  • Do not match '{} as there is no value to extract.
- case Const(null) =>
+ case '{null} =>

- case Const(()) =>
+ case '{} =>

We specialize use the old, faster, implementation for Unliftable as there it correct by the construction of the available Unliftables. We only need to add a null check for StringUnliftable.

* Make sure the extrators does not match classes. This should be done using reflection.
* Do not match `'{null}` to avoid accidental NPEs.
* Do not match `'{}` as there is no value to extract.

```diff
- case Const(null) =>
+ case '{null} =>

- case Const(()) =>
+ case '{} =>
```

We specialize use the old, faster, implemtation for `Unliftable` as there it it correct by construction of the available `Unliftable`s.
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nicolasstucki
Copy link
Contributor Author

@liufengyun small correction, we also need to check for null in StringUnliftable

@nicolasstucki nicolasstucki merged commit 067cc79 into scala:master Dec 1, 2020
@nicolasstucki nicolasstucki deleted the path-const-extractor branch December 1, 2020 21:56
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants